#ifndef REUTERSDATAVIEW_HPP
#define REUTERSDATAVIEW_HPP

#include <QSet>
#include <QList>
#include <QAbstractListModel>

class ReutersDocument;


class ReutersDataView : public QAbstractListModel {

    QList <ReutersDocument*> docList_;

    QSet <ReutersDocument*> docSet_;

    QList <ReutersDocument*>* allDocs_;

    int setCount_;

public:

    ReutersDataView ();

    void setAllDocuments (QList <ReutersDocument*>& allDocs) {
        allDocs_ = &allDocs;
    }

    void add (const QSet<ReutersDocument*>&);

    void clear ();

    void updateFinished ();

    virtual int rowCount (const QModelIndex& parent = QModelIndex()) const;

    virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;

    ReutersDocument* getDocAt(QModelIndex index) {
        return setCount_ != 0 ? docList_.at(index.row()) : allDocs_->at(index.row());
    }

    bool contains (ReutersDocument* document) const {
        return docSet_.contains(document);
    }

    int docsTotal() const {
        return allDocs_->size();
    }

    int docsFiltered() const {
        return setCount_ != 0 ? docList_.size() : docsTotal();
    }

};

#endif // REUTERSDATAVIEW_HPP
